package com.jiayang.hhotel.view;

import android.app.Dialog;
import android.content.Context;
import android.view.View;

import com.jiayang.hhotel.R;

public class CustomDialog extends Dialog {

    public CustomDialog(Context context) {
        super(context);
    }

    public CustomDialog(Context context, int theme) {
        super(context, theme);
    }

    public static class Builder {
        private Context context;
        private boolean is = false;//点击对话框外侧是否消失
        private View mView;//对话框布局

        public Builder(Context context) {
            this.context = context;
        }

        public void setCanceledOnTouchOutside(boolean is) {
            this.is = is;
        }

        public Builder setLayout(View mView) {
            this.mView = mView;
            return this;
        }

        /**
         * 创建dialog
         */
        public CustomDialog create() {
            // instantiate the dialog with the custom Theme
            final CustomDialog dialog = new CustomDialog(context,
                    R.style.CustomDialog);
//            dialog.addContentView(mView, new LayoutParams(
//                    LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
            dialog.setContentView(mView);
            dialog.setCanceledOnTouchOutside(is);
            return dialog;
        }
    }
}
